import BaseComponent from "http://component.119safe.cn/component/base.js";

new class Side_Menu_Item extends BaseComponent
{
	/*
	 * link			超级链接指向
	 * icon			图标(font-awesome class)
	 * text			菜单项内容
	 * active		是否当前选中的项(并且展开)
	 */
	Properties = { "link": "", "icon": "", "text": "", "active": "" };

	InnerContainer = "ul.submenu";

	render() { super.render(this.constructor.name); }

	preRender(elem)
	{
		if (this.Properties.link == "") this.Properties.toggle = "dropdown-toggle"; else this.Properties.toggle = "";
		if (this.Properties.icon != "") this.Properties.icon = `<i class="menu-icon fa ${this.Properties.icon}"></i>`;
		if (this.Properties.active == "1") this.Properties.active = "active open";
		if (elem.innerHTML != "") this.Properties.subpoint = '<b class="arrow fa fa-angle-down"></b>'; else this.Properties.subpoint = "";
	}

	Content = `
<li class="{active}">
	<a href="{link}" class="{toggle}">
		{icon}
		<span class="menu-text">{text}</span>
		{subpoint}
	</a>
	<ul class="submenu"></ul>
</li>
`;
}().render();
